package com.gitee.wsl.mathematics.matrix.mat3.ext

import com.gitee.wsl.mathematics.matrix.mat3.Matrix3
import com.gitee.wsl.mathematics.matrix.mat3.MutableMatrix3
import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3

val <T:Number> Matrix3<T, *,*>.scale get() = createVec2(sqrt(m00 * m00 + m01 * m01),sqrt(m10 * m10 + m11 * m11))

fun<T:Number> MutableMatrix3<T, *,*>.scale(sx: T, sy: T){
    n[0]*=sx
    n[1]*=sy
}

fun<T:Number> MutableMatrix3<T, *,*>.scale(scale: Vector2<T,*>) = scale(scale.x, scale.y)

/**
 * Inplace operation: Scales this matrix by the given factors.
 */
fun<T:Number> MutableMatrix3<T, *,*>.scale(s: Vector3<T,*>) = mul(
    s.x, zero, zero,
    zero, s.y, zero,
    zero, zero, s.z
)